package itheima.com.Test;

import java.io.*;

public class Test4 {
    public static void main(String[] args) throws IOException, ClassNotFoundException {
//        method01();

        method02();

    }

    private static void method02() throws IOException, ClassNotFoundException {
        ObjectInputStream ois = new ObjectInputStream(new FileInputStream("a.txt"));
        User o = (User) ois.readObject();
        System.out.println(o);
        ois.close();
    }

    private static void method01() throws IOException {
        User user = new User("DG","38");
        ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream("a.txt"));
        oos.writeObject(user);
        oos.close();
    }
}
